package com.wyp168.leetcode.entity;

/**
 * @ClassName SplitSolution
 * @Title TODO
 * @Description TODO
 * @Author wyp168
 * @Date 2022/10/10 20:23
 */
public class SplitSolution {
    public static void main(String[] args) {
        SplitSolution solution = new SplitSolution();
        String s = "www.baidu.com?abc=123&def=456";
        System.out.println(solution.splitMethod(s));
    }

    public String splitMethod (String s) {
        String[] split = s.split("\\?");
        String subString = split[1];
        String[] split1 = subString.split("&");

        String result = "{";

        for (int i = 0; i < split1.length; i++) {
            String[] str = split1[i].split("=");
            result += "\'" + str[0] + "\'" + ":" + "\'" + str[1] + "\'" + ",";
        }

        return result.substring( 0, result.length() - 1) + "}";
    }
}
